#include <bits/stdc++.h>
// 2025/01/23
// tag: 
// Author: Zhang Muen
using namespace std;

int n, k, p, m;
vector<int> q = {1};
unordered_set<int> del;
signed main()
{
    cin >> n;
    for (int i = 2; i <= n; i++){
        cin >> k >> p;
        q.insert(find(q.begin(), q.end(), k) + p, i);
    }
    cin >> m;
    for (int i = 0; i < m; i++){
        cin >> k;
        del.insert(k);
    }
    for (auto x: q){
        if (del.count(x))
            continue;
        cout << x << " ";
    }
    return 0;
}